package io.babystar.modules.business.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import io.babystar.modules.business.entity.CourseDateEntity;
import io.babystar.modules.business.service.CourseDateService;
import io.babystar.common.utils.PageUtils;
import io.babystar.common.utils.R;



/**
 * 
 *
 * @author jeson
 * @email 574197743@qq.com
 * @date 2021-03-23 20:03:34
 */
@RestController
@RequestMapping("business/coursedate")
public class CourseDateController {
    @Autowired
    private CourseDateService courseDateService;

    /**
     * 列表
     */
    @PostMapping("/list")
    @RequiresPermissions("business:coursedate:list")
    public R list(@RequestBody Map<String, Object> params){
        PageUtils page = courseDateService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @GetMapping("/info/{id}")
    @RequiresPermissions("business:coursedate:info")
    public R info(@PathVariable("id") Long id){
		CourseDateEntity courseDate = courseDateService.getById(id);

        return R.ok().put("courseDate", courseDate);
    }

    /**
     * 保存
     */
    @PostMapping("/save")
    @RequiresPermissions("business:coursedate:save")
    public R save(@RequestBody CourseDateEntity courseDate){
		courseDateService.save(courseDate);

        return R.ok();
    }

    /**
     * 修改
     */
    @PostMapping("/update")
    @RequiresPermissions("business:coursedate:update")
    public R update(@RequestBody CourseDateEntity courseDate){
		courseDateService.updateById(courseDate);

        return R.ok();
    }

    /**
     * 删除
     */
    @PostMapping("/delete")
    @RequiresPermissions("business:coursedate:delete")
    public R delete(@RequestBody Long[] ids){
		courseDateService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
